package com.battle.service.controller.web;

import com.battle.pojo.param.personCallRecord.*;
import com.battle.pojo.vo.personCallRecord.*;
import com.battle.service.service.in.*;
import com.battle.service.utils.FileUtil;
import jakarta.servlet.http.HttpServletResponse;
import nirvana.core.domains.vo.PageResult;
import nirvana.core.domains.vo.ApiResult;
import org.springframework.web.bind.annotation.*;

import jakarta.validation.Valid;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
import java.util.List;

/**
 * web/人员出警记录
 * 【描 述】：
 * 【环 境】：J2SE
 * 【详 细】：
 */
@RestController
@RequestMapping("/personCallRecord/web")
public class PersonCallRecordWebController {

    private final PersonCallRecordService service;

    public PersonCallRecordWebController(PersonCallRecordService service) {
        this.service = service;
    }


    /**
     * 获取人员出警记录列表
     *
     * @param param
     * @return
     */
    @PostMapping("/getPersonCallRecordList")
    public ApiResult<PageResult<GetPersonCallRecordListVo>> getPersonCallRecordList(@RequestBody GetPersonCallRecordListParam param) {
        PageResult<GetPersonCallRecordListVo> result = service.getPersonCallRecordList(param);
        return ApiResult.ok(result);
    }

    /**
     * 下载模板
     *
     * @param response
     */
    @PostMapping(value = "/downTemplate")
    public void downTemplate(HttpServletResponse response) {
        //模板名称
        String fileName = "personCallRecord.xlsx";
        FileUtil.downloadFile(response, fileName);
    }

    /**
     * 导入出警记录
     * @param param
     */
    @PostMapping("/importPersonCallRecord")
    public ApiResult importPersonCallRecord(@RequestBody ImportPersonCallRecordParam param) throws IOException {
        service.importPersonCallRecord(param);
        return ApiResult.ok();
    }

}

